home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4651 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: uni-erlangen.de!winx03!sunshine!lemmi
  2. From: lemmi@informatik.uni-wuerzburg.de (Martin Lehmann)
  3. Newsgroups: comp.lang.c
  4. Subject: HELP : getkey
  5. Date: 6 Feb 1996 08:49:32 GMT
  6. Organization: University of Wuerzburg, Germany
  7. Message-ID: <4f74ms$hll@winx03.informatik.uni-wuerzburg.de>
  8. NNTP-Posting-Host: wi2x01.informatik.uni-wuerzburg.de
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11.  
  12.  
  13. --
  14. Hello !
  15.     
  16. How do I make it to wait for a key pressed on the console (GNU C) ?
  17. I tried the following thing (using the CURSES-Libraray):
  18.  
  19.    char key;
  20.           
  21.    key = getch();
  22.           
  23. This has the disadvantage, that the program is waiting for a key EXCLUSIVELY
  24. and nothing else can be done. What I want is to REACT on keys pressed within
  25. a bigger loop. I do not want to wait for the user having pressed a key; the
  26. program should continue :
  27.        
  28.    char key;
  29.    while (no key pressed up to now && loop not ready)
  30.    {
  31.       if (keypressed)
  32.       {
  33.          key=getch();
  34.          switch (key)
  35.          {
  36.            ...
  37.          }
  38.       }
  39.       else
  40.       {
  41.          do the things of the big loop ...
  42.       }
  43.    }
  44.  
  45.  
  46. Has anyone an idea ?
  47. Thanx and CU, Martin 
  48. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  49. = Martin Lehmann            _/_/    _/_/   lemmi@informatik.uni-wuerzburg.de =
  50. = Basillastrasse 9         _/  _/ _/ _/                                      =
  51. = 97506 Grafenrheinfeld   _/    _/  _/            Corollar to Murphy's Laws: =
  52. = 09723 / 4486           _/        _/_/_/_/         Murphy was an optimist ! =
  53. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  54.